<extend name="Public:base" />
<block name="left">
    <ul class=" ">
          <li><a href="{:U('Person/auth')}">           实名认证</a></li>
        <li><a href="{:U('Person/set_pwdtrade')}">   交易密码设置</a></li>
        <li><a href="{:U('Person/updatepwd')}">      修改登录密码</a></li>
        <li><a href="{:U('Person/change_pwdtrade')}">修改交易密码</a></li>
        <li><a href="{:U('Person/forgot_pwdtrade')}">找回交易密码</a></li>
     
        <li><a href="{:U('Person/mail_check')}">邮箱验证</a></li>
      <!--   <li><a href="">邮件通知</a></li>
         <li><a href="">设置双重验证</a></li>
        <li><a href="">手机绑定</a></li>
      -->
    </ul>
</block>
<block name="right">

<div class="ziliao">
    <br>
    <br>
    <if condition="$userinfos['email'] eq ''">
    <form action="{:U('Person/check_mail')}" method="POST" onsubmit="return check_mail()">

      <div>
         邮箱地址：
         <input type="text" name="e_mail" id="e_mail" class="ziliaobucz"><br>
         <br>
         验 证 码：
         <input type="text" name="check_code" id="check_code" class="ziliaobucz">
         <input type="button" class="ziliaobu" name="send_btn" id="send_btn" value="发送邮件" onclick="send_mail()"><br>
         <br>
         <br>
         <input type="submit" name="submit" value="提交" class="ziliaobu"> &nbsp &nbsp
         <input type="reset" name="reset" value="重置" class="ziliaobu">
      </div>
      <script type="text/javascript">
       function send_mail() {
          var mail = document.getElementById('e_mail').value;
          var reg =  /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
          if (!reg.test(mail)) {
              alert('邮箱格式不正确');
          }else{
              $.ajax({
                  url:"{:U('Person/send_check_mail')}" ,
                  type: 'post',
                  dataType: 'text',
                  data: {
                    'e_mail':mail    
                  },
                  success: function(){
                    alert('发送成功'); 
                  },
                  error: function(){
                    alert('发送失败');  
                  }
               }) 
          }
       }

     function check_mail(){
        var mail = document.getElementById('e_mail').value;
        var code = document.getElementById('check_code').value;
        var reg =  /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
        var err_msg = '';

        if (!reg.test(mail)) {
          err_msg += '邮箱格式不正确\n';
        }

        if (code == '') {
          err_msg += '验证码不能为空\n';
        }

        if (err_msg != '') {
          alert(err_msg);
          return false;
        }

        return true;

     }
      </script> 
    </form>
    <else /> 
    <h1>您的邮箱已验证</h1>
    </if>

 </div>    
</block>